package com.wachulski.marcin.msc.script;

import com.wachulski.marcin.msc.pl.PLQuery;
import com.wachulski.marcin.msc.pl.PLScript;
import com.wachulski.marcin.msc.utils.FilePaths;
import com.wachulski.marcin.msc.utils.KBWarehouse;

import edu.isi.powerloom.Environment;
import edu.isi.powerloom.PLI;

public final class ScriptRunner {
	public static void main(String[] args) {
		PLI.initialize();
		Environment env = PLI.INFERENCE_ENV;
		
		PLI.load(KBWarehouse.KB_BASIC_FOUNDATION.getFilePath(), env);
		PLI.load(KBWarehouse.KB_BASIC_SYSTEM.getFilePath(), env);
		PLI.load(KBWarehouse.KB_BASIC_BOUNDARY.getFilePath(), env);
		
		PLI.load(KBWarehouse.KB_EXT_CAT.getFilePath(), env);
		
		PLScript script = new PLScript("main_script", FilePaths.PLT_ROOT + "/basic/script.plm");
		for (PLQuery q : script.getQueries()) {
			System.out.print(q.getName() + " = ");
			System.out.println(PLI.sEvaluate(q.getBody(), 
						KBWarehouse.KB_BASIC_BOUNDARY.getModulePath(), env).toString());
		}
	}
}
